package com.tj.admin.rest;

import com.fqgj.base.services.redis.RedisClient;
import com.fqgj.common.api.Response;
import com.jsoniter.output.JsonStream;
import com.qianli.cashmama.product.facade.ProductFacade;
import com.qianli.cashmama.product.facade.result.ProductCategory;
import com.tj.admin.annotations.AdminSignIgnore;
import com.tj.admin.auth.anno.VisitorAccessible;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: binary (mr.vencnet@gmail.com)
 * Date: 2020-06-02
 * Time: 17:18
 */
@RestController
public class OkController {

    private static final Logger LOGGER = LoggerFactory.getLogger(OkController.class);

    @Autowired
    private RedisClient redisClient;

    @Autowired
    private ProductFacade productFacade;

    @AdminSignIgnore
    @RequestMapping("/ok")
    @VisitorAccessible
    public String ok() {
        redisClient.set("aa", "1111");
        return redisClient.get("aa");
    }

    @AdminSignIgnore
    @RequestMapping("/ok1")
    @VisitorAccessible
    public String ok1() {
        Response<List<ProductCategory>> allProductCategory = productFacade.getAllProductCategory();

        return JsonStream.serialize(allProductCategory.getData());
    }

}
